#pragma once
#include <queue>
#include <mutex>
#include <thread>
using namespace std;
typedef void (*callback) (void* arg);
template <typename T>
struct Task 
{
	callback f;
	T* arg;
	Task():f(nullptr),arg(nullptr) {}
	Task(callback func, void* arg1) :f(func), arg((T *)arg1) {}

};
template <typename T>
class TaskQueue
{
public:
	~TaskQueue();
	void addTask(Task<T> task);
	Task<T> takeTask();
	inline size_t taskNumber()
	{
		std::unique_lock<std::mutex> locker(m_mutex);
		return m_TaskQueue.size();
	}

private:
	queue<Task<T>> m_TaskQueue;
	mutex m_mutex;
	
};

